package com.csdj.springcloudt309.webfluxdemo.controller;

import com.csdj.spingcloudt309.common.WebResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("/webflux")
public class TestController {

    @GetMapping("/test")
    public Mono<WebResult> test(@RequestParam("id")Integer id,
                                ServerWebExchange exchange){
        String name = exchange.getRequest().getHeaders().getFirst("name");
        System.out.println(String.format("header %s:%s","name",name));
        WebResult webResult = new WebResult();
        webResult.setCode(id);
        webResult.setMsg("test");
        webResult.getResult().put("data","esdfsdfsdfs");
        return Mono.just(webResult);

    }
}
